﻿function removeOptionSelected(id) {
	var elSel = document.getElementById(id);
	var i;
	for ( var i = elSel.length - 1; i >= 0; i--) {
		if (elSel.option[i].selected) {
			elSel.remove(i);
		}
	}
}

function appendOption(id1, id2) {
	for ( var i = 0; i < document.getElementById(id1).options.length; i++) {
		if (document.getElementById(id1).options[i].selected) {
			title = document.getElementById(id1).options[i].text;
			giatri = document.getElementById(id1).options[i].value;
			addOption(id2, giatri, title);
		}
	}
	removeOptionSelected(id1);
}

function addOption(id2, giatri, title) {
	checkthemoi = 1;
	for ( var j = 0; j < document.getElementById(id2).options.length; j++) {
		if (document.getElementById(id2).options[j].value == giatri) {
			checkthemoi = 0;
			break;
		}
	}
	if (checkthemoi == 1) {
		var elOptNew = document.createElement('option');
		elOptNew.text = title;
		elOptNew.title = title;
		elOptNew.value = giatri;
		var elSel = document.getElementById(id2);
		try {
			elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
		} catch (e) {
			elSel.add(elOptNew); // IE only
		}
	}
}

function selectAll(id) {
	for ( var i = 0; i < document.getElementById(id).options.length; i++) {
		document.getElementById(id).options[i].selected = true;
	}
}

function removeOptionLast() {
	var elSel = document.getElementById('room_select');
	if (elSel.length > 0) {
		elSel.remove(elSel.length - 1);
	}
}